﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace students__info_save_into_file
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = @"D:\New\Students List.txt";
            StudentsList newList = new StudentsList();
            int 
        }
    }

    class Student
    {   
            public int id;
            public string firstName;
            public string lastName;
        
        public void PrintStudentinfo()
        {
            Console.WriteLine("Student id - {0}: {1} {2}", id, firstName, lastName);
        }
    }


    class StudentsList
    {
        public List<Student> students = new List<Student>();

        public static StudentsList ImportFromFile(string path)
        {
            StudentsList list = new StudentsList();
            string file = File.ReadAllText(path);
            string[] fileArr = file.Split(new string[] { "---" + System.Environment.NewLine }, StringSplitOptions.None);
            foreach (string studentStr in fileArr)
            {
                string[] strArr = studentStr.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None);
                Student newSt = new Student();
                newSt.id = Int32.Parse(strArr[0]);
                newSt.firstName = strArr[1];
                newSt.lastName = strArr[2];
                list.students.Add(newSt);
            }
            return list;
        }
    }
